home *** CD-ROM | disk | FTP | other *** search
/ NetNews Offline 2 / NetNews Offline Volume 2.iso / news / comp / std / c++ / 1155 < prev    next >
Encoding:
Internet Message Format  |  1996-08-06  |  2.4 KB

  1. Path: fido.asd.sgi.com!austern
  2. From: kanze@gabi-soft.fr (J. Kanze)
  3. Newsgroups: comp.std.c++
  4. Subject: Re: 'const' binding to specifier in declaration list
  5. Followup-To: comp.std.c++
  6. Date: 18 Apr 1996 09:42:19 PDT
  7. Organization: GABI Software, Sarl.
  8. Approved: austern@isolde.mti.sgi.com
  9. Message-ID: <KANZE.96Apr18103420@gabi.gabi-soft.fr>
  10. References: <3173B383.41C67EA6@rstcorp.com>
  11.     <KANZE.96Apr17121453@slsvgqt.lts.sel.alcatel.de>
  12. NNTP-Posting-Host: isolde.mti.sgi.com
  13. X-Original-Date: 18 Apr 1996 08:34:20 GMT
  14. In-reply-to: kanze@lts.sel.alcatel.de's message of 17 Apr 1996 10:41:47 PDT
  15. X-Auth: PGPMoose V1.1 PGP comp.std.c++
  16.     iQBVAwUBMXZw7Uy4NqrwXLNJAQHjtwH/bUDdICpZMboVzSfIK5xdkNScrm7GasM9
  17.     gWiY9TJ7ae1d8h5VwpN+CRU+lUaCjaB0j3Os39ZMsmENX3KZKrY/QQ==
  18.     =imfj
  19. Originator: austern@isolde.mti.sgi.com
  20.  
  21. In article <KANZE.96Apr17121453@slsvgqt.lts.sel.alcatel.de>
  22. kanze@lts.sel.alcatel.de (James Kanze US/ESC 60/3/141 #40763) writes:
  23.  
  24. |> In article <3173B383.41C67EA6@rstcorp.com> "Aaron S. Binns"
  25. |> <asbinn@rstcorp.com> writes:
  26.  
  27. |> |> [Moderator's note: This is crossposted to comp.std.c++ and
  28. |> |> comp.lang.c++, and followups have been set to comp.std.c++. mha]
  29.  
  30. |> |> I recently came across a piece of code that reads:
  31.  
  32. |> |> class A {
  33. |> |>   // contents of class A
  34. |> |> } a1, *a2, const *a3;
  35.  
  36. |> While I personally wouldn't write anything like this, it is definitly
  37. |> legal.
  38.  
  39. Actually, on further thought, I don't think it is legal.  In the statement:
  40.  
  41.     A const*        a3 ;
  42.  
  43. The const is part of the `declaration-specifiers', and not the
  44. `declarator'.  When multiple symbols are declared in the same line, as
  45. here, the list contains declarators, and cannot contain additional parts
  46. of the declaration-specifiers.
  47.  
  48. A quick check of the grammar shows that the first token of a declarator
  49. must be one of { `*', `(' , <identifier> }.  The keyword `const' is none
  50. of these.
  51. -- 
  52. James Kanze           (+33) 88 14 49 00          email: kanze@gabi-soft.fr
  53. GABI Software, Sarl., 8 rue des Francs Bourgeois, 67000 Strasbourg, France
  54. Conseils en informatique industrielle --
  55.                             -- Beratung in industrieller Datenverarbeitung
  56. ---
  57. [ comp.std.c++ is moderated.  To submit articles: Try just posting with your 
  58.                 newsreader.  If that fails, use mailto:std-c++@ncar.ucar.edu
  59.   comp.std.c++ FAQ: http://reality.sgi.com/austern/std-c++/faq.html
  60.   Moderation policy: http://reality.sgi.com/austern/std-c++/policy.html
  61.   Comments? mailto:std-c++-request@ncar.ucar.edu 
  62. ]
  63.